package com.yhl.springtest.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author: yanghl
 * @description: TODO
 * @date: 2023/8/15 15:04
 */
@Component
@Aspect
public class MyAspect {

    // 第一个*
    @Pointcut("execution(* com.yhl.springtest..*())")
    public void joinPoint(){}

    @Before("joinPoint()")
    public void before(){
        System.out.println("===========before============");
    }

    @After("joinPoint()")
    public void After(){
        System.out.println("===========After============");
    }

    @Around("joinPoint()")
    public Object Around(ProceedingJoinPoint pjp){
        Object proceed = new Object();
        try {
            System.out.println("===========Around1============");
            proceed = pjp.proceed();
            System.out.println("===========Around2============");
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return proceed;
    }

    @AfterReturning("joinPoint()")
    public void AfterReturning(){
        System.out.println("===========AfterReturning============");
    }


}

